﻿    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="jieshouxinxi.aspx.cs" Inherits="jieshouxinxi" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>接收消息</title>
        <script type="text/javascript" language="javascript">
                function CheckAll(form){
                    for (var i=0;i<form.elements.length;i++){
                    var e = form.elements[i];
                    if (e.name != 'chkAll')
                    e.checked = form.chkAll.checked;
                }
        }
        </script>
    <script type="text/javascript" language="javascript">

      function check()//表单判断
      {
       var str="";
       var j=0;
       var el=document.form1.getElementsByTagName("input")
       for(i=0;i<el.length;i++){
        if(el[i].type=="checkbox"){
         if((el[i].checked)&&(el[i].name.indexOf("deletecheck")!='-1')){
          j++;
         }
        }
       }
       if(j > 10000 || j<1)
       {
        alert("最少必须选择一项，最多不能超过100项!\r\t你现在选择了"+j+"项");
        return false;
       }
       
         if(!confirm('您确定要删除该记录吗？'))
     {
    return false
    } 
    else 
    document.form1.submit
    }
      
      </script>
        <style type="text/css"> 

    div.RoundedCorner{background: #5AAE18} 

    b.rtop, b.rbottom{display:block;background: #FFF} 

    b.rtop b, b.rbottom b{display:block;height: 1px;overflow: hidden; background: #5AAE18} 

    b.r1{margin: 0 4px} 

    b.r2{margin: 0 3px} 

    b.r3{margin: 0 2px} 

    b.rtop b.r4, {margin: 0 1px;height: 1px}

    .style1 {

	    font-size: 13px;

	    color: #FFFFFF;

    font-weight: bold;

    } 

    </style>
        <link href="../css/textarea.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    body {
	    margin-top: 2px;
    }
    -->
    </style>
    </head>
    <body>
        <form name="form1" id="form1" onsubmit="return check();" action="deletejieshoucheck.aspx">
            <table border="0" bgcolor="#5AAE18">
                <tr bgcolor='#FFFFFF'>
                <td colspan="6" align="center">
                    <div class="RoundedCorner"> 
    <b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b> <span class="style1">接 收 消 息</span></div></td>
                    
                </tr>
                <tr bgcolor='#FFFFFF'>
                    <td style="width: 59px; height: 1px; text-align: center;" align="center">
                        <input  type="submit" name="Submit"  value="删除" />
                        </td>
                    <td style="width: 938px; height: 1px" align="center">
                        标题</td>
                    <td style="width: 103px; height: 1px;" align="center">
                        读否</td>
                     <td style="width: 79px; height: 1px;" align="center">
                         转发</td>
                     <td style="width: 101px; height: 1px;" align="center">
                         接收人</td>
                     <td style="width: 270px; height: 1px;" align="center">
                         时间</td>
                </tr>
                <%  
                    //取登陆人信息 
                    COM.OA.Entity.users loginuser =Session["loginuser"] as COM.OA.Entity.users;
                    //如果取不到跳转到登陆页
                    if (loginuser == null)
                    {
                        this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
                    }
                    else
                    {
                        //取登陆人ＩＤ
                        int LoginName = loginuser.u_id;
                        //取当前页
                        string page = this.Request["page"];
                        //声明全局变量
                        System.Collections.Generic.IList<COM.OA.Entity.message> list;
                        //设置where语句
                        string where = " m_u_id='{0}'";
                        where = string.Format(where, LoginName);
                        //查询
                        list = COM.OA.BLL.messageBLL.Select(where);
                        //取数据库相关信息总条数
                        int count = list.Count;
                        //int转换成float类型
                        float countd = count;
                        //调用ceiling方法转换取值并转换成double类型
                        double weiy = Math.Ceiling(countd / 3);
                        //转换成int类型
                        int weiye = Int32.Parse(weiy.ToString());
                        int pages = 1;
                        int shangpage = 0;
                        int xiapage = 0;
                        //判断是否第一次登陆，是就查前3条信息
                        if (page == null)
                        {
                            list = COM.OA.BLL.messageBLL.Select(3, 1, where);

                            shangpage = 1;
                            xiapage = 2;
                        }
                        //不是第一次登陆按页数查询
                        else
                        {
                            pages = Int32.Parse(page);
                            shangpage = pages - 1;
                            xiapage = pages + 1;
                            list = COM.OA.BLL.messageBLL.Select(3, pages, where);

                        }
                        //判断查询出的内容是否为空
                        if (list.Count != 0)
                        {
                            foreach (COM.OA.Entity.message m in list)
                            {
                                //把ID转换成人名
                                string where1 = "u_id='{0}'";
                                where1 = string.Format(where1, m.m_u_id);
                                System.Collections.Generic.IList<COM.OA.Entity.users> ulist = COM.OA.BLL.usersBLL.Select(where1);
                                COM.OA.Entity.users u = ulist[0];
                                int uid = u.u_em_id;
                                string where2 = "em_id='{0}'";
                                where2 = string.Format(where2, uid);
                                System.Collections.Generic.IList<COM.OA.Entity.employee> emlist = COM.OA.BLL.employeeBLL.Select(where2);
                                COM.OA.Entity.employee em=emlist[0];
                                
                                if (m.m_isreturn == 0)
                                {
                                 %>
                                 <tr bgcolor='#FFFFFF'>
                    <td style="width: 59px; height: 24px;background-color: #ccff99;" align="center" colspan="">
                        <input type="checkbox" name="deletecheck" value="<%=m.m_id %>" /></td>
                    <td style="width: 938px; height: 24px;background-color: #ccff99;" align="center">
                        &nbsp;&nbsp;<a href="chakanjiluneirong.aspx?id=<%=m.m_id %>"><%=m.m_title%></a><img src="../images/wximg/new-028.gif" />
                    <td style="width: 103px; height: 24px;background-color: #ccff99;">
                        &nbsp;&nbsp;否
                    
                    </td>
                     <td style="width: 79px; height: 24px;background-color: #ccff99;">
                      <a href="fasongxiaoxi.aspx?name=<%=LoginName %>&datetime=<%=m.m_releasetime %>">转发</a>
                    </td>
                     <td style="width: 101px; height: 24px;background-color: #ccff99;">
                     <%=em.em_name%>
                    </td>
                     <td style="width: 270px; height: 24px;background-color: #ccff99;">
                     <%=m.m_releasetime%>
                    </td>
                </tr>
                                 <%
                    }
                    else if (m.m_isreturn == 1)
                    {
                %>
                <tr bgcolor='#FFFFFF'>
                    <td style="width: 59px" align="center" colspan="">
                        <input type="checkbox" name="deletecheck" value="<%=m.m_id %>" /></td>
                    <td style="width: 938px" align="center">
                        &nbsp;&nbsp;<a href="chakanjiluneirong.aspx?id=<%=m.m_id %>"><%=m.m_title%></a>
                    <td style="width: 103px">
                        &nbsp;&nbsp;是
                    
                    </td>
                     <td style="width: 79px">
                      <a href="fasongxiaoxi.aspx?name=<%=LoginName %>&datetime=<%=m.m_releasetime %>">转发</a>
                    </td>
                     <td style="width: 101px">
                     <%=em.em_name%>
                    </td>
                     <td style="width: 270px">
                     <%=m.m_releasetime%>
                    </td>
                </tr>
                <%
                    }
                }
                            %>
                            
                               <tr bgcolor='#FFFFFF'>
                    <td colspan="6">
                        <% 
                        if (pages == 1)
                           { %>
                            <a href="jieshouxinxi.aspx?page=1">首页</a>                    
                        
                        <%}
                          else
                          { %>
                        <a href="jieshouxinxi.aspx?page=<%=shangpage %>">上一页</a>
                        <% } %>&nbsp
                         <% if (pages == weiye)
                            {  %> <a href="jieshouxinxi.aspx?page=<%=weiye %>">尾页</a>
                         <% }
                            else
                            {  %> <a href="jieshouxinxi.aspx?page=<%=xiapage %>">下一页</a>
                         <% }%>
                      
                         </td>                
                </tr>
                            
                            <%
            }
                            %>
            <%   else
            {
              %>
                     <tr bgcolor='#FFFFFF'>
                    
                    <td colspan="6" style="text-align: center">
                        <strong><span style="font-size: 24pt">
                        无接受消息</span></strong></td>
                    
                </tr>
                <% } %>       
                <tr bgcolor='#FFFFFF'>
                    <td style="width: 59px; height: 4px;">
                        <input name="chkAll" type="checkbox" onclick="CheckAll(this.form)" /></td>
                    <td colspan="5">
                        全选</td>
                    
                </tr>
              
                 <% } %>
                 <tr bgcolor='#FFFFFF'>
                    <td style="width: 59px; height: 4px;"><input  type="submit" name="Submit" value="删除" /></td>
                    <td style="width: 938px; height: 4px">
                        </td>
                    <td style="width: 103px; height: 4px;">
                    </td>
                     <td style="width: 79px; height: 4px;">
                    </td>
                     <td style="width: 101px; height: 4px;">
                    </td>
                     <td style="width: 270px; height: 4px;">
                    </td>
                </tr>
            </table>            
        </form>     
        
    </body>
    </html>
